package com.zqxq.lottery.entity.o2o.user;

import com.zqxq.common.utils.BigDecimalUtils;
import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.lottery.entity.po.user.UserCashPO;
import com.zqxq.lottery.entity.vo.user.UserCashVO;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2018/03/14 16:15
 */
public class UserCashO2O {

    public static UserCashVO toVO(UserCashPO po) {
        if (po == null) {
            return null;
        }
        UserCashVO userCashVO = new UserCashVO();
        userCashVO.setId(DispatcherUtils.parseString(po.getId()));
        userCashVO.setUserId(DispatcherUtils.parseString(po.getUser_id()));
        userCashVO.setRealName(po.getReal_name());
        userCashVO.setMobile(po.getMobile());
        userCashVO.setPayWay(DispatcherUtils.parseString(po.getPay_way()));
        userCashVO.setPayAccount(po.getPay_account());
        BigDecimal payAmountDecimal = BigDecimalUtils.getValue(po.getPay_amount(),2) ;
        String payAmount = payAmountDecimal == null ? null : payAmountDecimal.toPlainString();
        userCashVO.setPayAmount(payAmount);
        BigDecimal remainderDecimal = BigDecimalUtils.getValue(po.getRemainder(),2) ;
        String remainder = remainderDecimal == null ? null : remainderDecimal.toPlainString();
        userCashVO.setRemainder(remainder);
        userCashVO.setType(DispatcherUtils.parseString(po.getType()));
        userCashVO.setStatus(DispatcherUtils.parseString(po.getStatus()));
        userCashVO.setAuditor(po.getAuditor());
        userCashVO.setInfo(po.getInfo());
        userCashVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        userCashVO.setUpdateTime(DispatcherUtils.parseDateTimeStr(po.getUpdate_time()));
        return userCashVO;
    }

    public static UserCashPO toPO(UserCashVO vo) {
        if (vo == null) {
            return null;
        }
        UserCashPO userCashPO = new UserCashPO();
        userCashPO.setId(DispatcherUtils.parseLong(vo.getId()));
        userCashPO.setUser_id(DispatcherUtils.parseLong(vo.getUserId()));
        userCashPO.setReal_name(vo.getRealName());
        userCashPO.setMobile(vo.getMobile());
        userCashPO.setPay_way(DispatcherUtils.parseInteger(vo.getPayWay()));
        userCashPO.setPay_account(vo.getPayAccount());
        userCashPO.setPay_amount(BigDecimalUtils.getBigDecimal(vo.getPayAmount()));
        userCashPO.setRemainder(BigDecimalUtils.getBigDecimal(vo.getRemainder()));
        userCashPO.setType(DispatcherUtils.parseInteger(vo.getType()));
        userCashPO.setStatus(DispatcherUtils.parseInteger(vo.getStatus()));
        userCashPO.setAuditor(vo.getAuditor());
        userCashPO.setInfo(vo.getInfo());
        userCashPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        userCashPO.setUpdate_time(DispatcherUtils.parseDateTime(vo.getUpdateTime()));
        return userCashPO;
    }

    public static List<UserCashVO> toVOList(List<UserCashPO> list){
        List<UserCashVO> result = new ArrayList();
        if(list != null && list.size() > 0){
            for (UserCashPO po : list) {
                result.add(toVO(po));
            }
        }
        return result;
    }


}
